#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int main()
{
	int n=3;
	ll st=0;
	ll sum=0;
	while(n--)
	{
		ll d1,d2;
		cin>>d1>>d2;
		sum+=abs(st-d1);
		st=d2;
	}
	cout<<sum;

	return 0;
}

